<template>
	<view>
		<view class="flex align-center justify-between padding-y-16 padding-x-30 nav_fixed_top">
			<view @click="goBack()">
				<image src="../../static/img/back.png" style="width: 30rpx;height: 30rpx;margin: 0 auto;"></image>
			</view>
			<view class="radius60 flex1 margin-x-30 padding-x-30 flex align-center" style="background: rgba(102, 102, 102, 0.08);">
				<image src="../../static/img/srh_6.png" style="width: 40rpx;height: 40rpx;"></image>
				<input v-model="q.keywords" @confirm="search()" type="text" class="fs-26 color-fff margin-left-20 ipt flex1" placeholder="请输入">
			</view>
			<view>
				<image  @click="sjump('/pages/msg/index')"  src="../../static/img/msg_6.png"  style="width: 46rpx;height: 46rpx;"></image>
			</view>
		</view>
		<!-- 分类 -->
		<view class="padding-20 bg-f7f7f7">
			<view class="flex align-center  flex-wrap bg-fff padding-top-24 padding-bottom-16">
				<view v-for="(item,index) in cate" :key='index' @click="jump('/pages/fangwu/two?id='+item.id+'&is_open='+item.is_open)" class="w20 text-center margin-bottom-24">
					<image :src="item.pic" class="index_icon"></image>
					<view class="fs-24 color-333">{{item.name}}</view>
				</view>
			</view>
		</view>
		<!-- 分类end -->

		
		<view class="clearfix  margin-top-10 padding-x-10">
			<!-- 商家列表 -->
			<view v-for="(item,index) in list" :key='index' @click="jump('/pages/fangwu/detail?id='+item.id)"  class="w50 fl padding-x-10  margin-bottom-30  bg-fff">
				<view class="goods_item padding-bottom-16">
					<image class="goods_img"  :src="item.thumb" mode="aspectFit"></image>
					<view class="margin-top-10 padding-x-20">
						<view class="goods_name text-cut-2">{{item.title}}</view>
						<view class="fs-24 color-999 margin-top-16">{{item.area}}cm² ·{{item.flat}} ·{{item.address}}</view>
						<!-- <view class="flex align-center margin-top-16">
							<text class="color-fuse fs-20" style="padding:4rpx 6rpx;transform: scale(0.8); border: 1rpx solid #FF932E;border-radius: 6rpx; ">押一付一</text>
							<text class="color-fuse fs-20" style="padding:4rpx 6rpx;transform: scale(0.8);  border: 1rpx solid #FF932E;border-radius: 6rpx; ">押一付一</text>
						</view> -->
						<view class="margin-top-10 fw-600 fs-20 color-zhuse">¥<text class="fs-26">{{item.price}}/</text> {{timeArr[item.time-1]}}</view>
					</view>
				</view>
			</view>

			
			<!-- 商家列表 end -->
		</view>
		<view class="nomore" :class="loadStatus" v-if="list.length"></view>
		<empty v-if="list.length < 1"></empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				flag:false,
				sortArr:['推荐排名','星级评价排名','距离优先','销量排名'],
				sortIndex:-1,
				filter:false,
				cate: [],
				q:{
					keywords:"",
					category_id:"",
					region:"",
					min_price:"",
					max_price:"",
					page:1,
				},
				hasMore: true,
				loadStatus: '',
				list: [],
				timeArr:['天','周','月','年'],
			}
		},
		onLoad(opt) {
			this.q.category_id = opt.id;
			this.init()
			this.getList();
		},
		onReachBottom() {
			if(this.hasMore){
				this.q.page += 1;
				this.getList();
			}
		},
		methods:{
			init() {
				this.$api.classify({
					pid: this.q.category_id
				}).then(res => {
					if (res.code == 1) {
						this.cate = res.data;
					}
				})
			},
			getList(){
				this.isLoading = true;
				this.$api.house_list(this.q).then(res=>{
					if(res.code == 1){
						this.isLoading = false;
						this.list = [...this.list, ...res.data.data];
						if (res.data.data.length != 0) {
							this.hasMore = true;
							this.loadStatus = '';
						} else {
							this.hasMore = false;
							this.loadStatus = 'over';
						}
					}
				})
			},
			search(){
				this.list = [];
				this.q.page = 1;
				this.getList();
			},
			
			changeSort(index){
				this.sortIndex = index;
				this.flag = false;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ipt{height: 70rpx;}
	.index_icon{width: 56rpx;height: 56rpx;}
	.sortCon{
		top: 70rpx;
		background: rgba(0,0,0,0.4);
		height: 100vh;
		z-index: 9;
	}
	.filterCon{width: 100%;height: 100vh;top: 0;left: 0;}
	.nav_item{background: rgba(153, 153, 153, 0.1);height: 60rpx;line-height: 60rpx; padding: 0 30rpx;border-radius: 60rpx;}
	.nav_item.on{background: rgba(255, 147, 46, 0.08);color: #FF932E;border: 1rpx solid #FF932E;}
	.btn1{width: 300rpx;height: 82rpx;line-height: 82rpx;border: 1rpx solid #FF932E;}
	.btn2{width: 300rpx;height: 82rpx;line-height: 82rpx;border: 1rpx solid #FF932E;}
</style>
